package com.beiding.my.common.query;

import com.beiding.my.common.Bo;
import com.beiding.my.common.QuoteExpressionRegistry;

public  class InnerCompareBetween extends InnerCompare{
    private String symbol;
    private String field;
    private Object from;
    private Object to;

    public InnerCompareBetween(Expression font) {
        super(font);
    }

    public void setField(String field) {
        this.field = field;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public void setTo(Object to) {
        this.to = to;
    }

    public void setFrom(Object from) {
        this.from = from;
    }
    @Override
    protected String createExpressionLocal(QuoteExpressionRegistry registry, Class<? extends Bo> type, ParamHolderCreator paramHolderCreator, CreateResult createResult) {
        QuoteExpressionRegistry.QuoteExpression quoteExpression = registry.getQuoteExpression(type, field);
        createResult.quoteConditions.addAll(quoteExpression.getQuoteConditions());
        String holder1 = paramHolderCreator.create();
        createResult.params.put(holder1, from);
        String holder2 = paramHolderCreator.create();
        createResult.params.put(holder2, to);
        createResult.beTypes.addAll(quoteExpression.getBeTypes());
        return quoteExpression.getExpression() + " " + symbol + " :" + holder1 + " and " + " :" + holder2;
    }
}
